package com.ml.mall.mapper;

import com.ml.mall.bean.req.admin.variant.VariantQueryPageReq;
import com.ml.mall.bean.res.admin.*;
import com.ml.mall.bean.res.admin.category.AdminCategoryQueryPageRes;
import com.ml.mall.bean.res.admin.category.AdminCategoryQueryReportPageRes;
import com.ml.mall.bean.res.admin.category.CategoryQuerySubcategoryTotalfeeRes;
import com.ml.mall.bean.res.admin.variant.VariantQueryPageRes;
import com.ml.mall.bean.res.admin.variant.VariantQueryTopRes;
import com.ml.mall.bean.res.admin.variant.vo.VariantQueryOneVO;
import com.ml.mall.bean.res.admin.variant.vo.VariantQueryTopVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByCategoryVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByCountryVO;
import com.ml.mall.bean.res.admin.vo.AdminOverviewSalesByIndustryVO;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryOneByCategoryRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryOneByPurchaseRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryPageRes;
import com.ml.mall.bean.res.admin.supplier.vo.SupplierQueryOneVO;
import com.ml.mall.bean.vo.CouponVO;
import com.ml.mall.bean.vo.DateValueVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by kyyang on 2021/6/8 23:01
 */
@Repository
public interface AnalyticsAdminMapper {

    //管理员查询洲属销售报告
    List<AdminOverviewSalesByCountryVO> selectSalesByStatesName(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd);

    List<AdminOverviewSalesByCountryVO> selectSupplierSalesByStatesName(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("supplierId") Long supplierId);

    /**
     * @description: 根据时间范围查询公司注册数量
     * @author kyyang
     * @date 2021/6/9 22:12
     * @version 1.0
     */
    List<DateValueVO> selectRegisterCompanyByDateRange( @Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("type") Integer type);

    /**
     * @description: 根据时间范围查询 券使用情况
     * @author kyyang
     * @date 2021/6/9 22:15
     * @version 1.0
     */
    List<CouponVO> selectCouponUsesByDateRange(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd);

    //管理员查询目录销售前10
    List<AdminOverviewSalesByCategoryVO> selectSalesByCategoryTopN(@Param("topN") int topN, @Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("companyId") Long companyId);
    List<AdminOverviewSalesByCategoryVO> selectSupplierSalesByCategoryTopN(@Param("topN") int topN, @Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("supplierId") Long supplierId,@Param("companyId") Long companyId);

    /**
     * @description: 根据时间范围 产业 （分类中） 查询 top N
     * @author kyyang
     * @date 2021/6/9 23:38
     * @version 1.0
     */
    List<AdminOverviewSalesByIndustryVO> selectSalesByIndustryTopN(@Param("topN") int topN, @Param("startTime") String timeBegin, @Param("endTime") String timeEnd);

    /**
     * @description: 查询时间范围内 销售金额汇总
     * @author kyyang
     * @date 2021/6/15 21:39
     * @version 1.0
     */
    BigDecimal selectSalesByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd);

    /**
     * @description: 查询时间范围内 买家订单数
     * @author kyyang
     * @date 2021/6/15 23:00
     * @version 1.0
     */
    List<DateValueVO> selectPurchaseOrderByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId);
    List<DateValueVO> selectSupplierPurchaseOrderByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId,@Param("supplierId") Long supplierId);

    //管理员 查询时间范围内 买家花费金额
    List<DateValueVO> selectPurchaseSpentByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId);
    //卖家 查询时间范围内 买家花费金额
    List<DateValueVO> selectSupplierPurchaseSpentByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId,@Param("supplierId") Long supplierId);

    /**
     * @description: 查询时间范围内 买家消费数量
     * @author kyyang
     * @date 2021/6/16 22:12
     * @version 1.0
     */
    Integer selectAdminPurchaseQueryReportPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyName") String companyName);
    Integer selectSupplierPurchaseQueryReportPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyName") String companyName,@Param("supplierId") Long supplierId);

    //管理员查询时间范围内 买家消费 记录汇总
    List<PurchaseReportPageRes> selectAdminPurchaseQueryReportPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyName") String companyName,@Param("start") int start,@Param("end") int end);
    //卖家查询时间范围内 买家消费 记录汇总
    List<PurchaseReportPageRes> selectSupplierPurchaseQueryReportPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyName") String companyName,@Param("start") int start,@Param("end") int end,@Param("supplierId") Long supplierId);

    /**
     * @description: 买家消费目录：分页查询 数量
     * @author kyyang
     * @date 2021/6/16 23:26
     * @version 1.0
     */
    int selectAdminPurchaseSpentByCategoryPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId);

    /**
     * @description: 买家消费目录：分页查询 记录明细
     * @author kyyang
     * @date 2021/6/16 23:35
     * @version 1.0
     */
    List<PurchaseByNameSpentRes> selectAdminPurchaseSpentByCategoryPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyId") Long companyId,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 买家消费卖家：分页查询 数量
     * @author kyyang
     * @date 2021/6/16 23:43
     * @version 1.0
     */
    int selectAdminPurchaseSpentBySupplierPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId);

    /**
     * @description: 买家消费卖家：分页查询 记录明细
     * @author kyyang
     * @date 2021/6/16 23:48
     * @version 1.0
     */
    List<PurchaseByNameSpentRes> selectAdminPurchaseSpentBySupplierPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyId") Long companyId,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 买家消费产品：分页查询 数量
     * @author kyyang
     * @date 2021/6/16 23:52
     * @version 1.0
     */
    int selectAdminPurchaseSpentByProductPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("companyId") Long companyId);

    /**
     * @description: 买家消费产品：分页查询 记录明细
     * @author kyyang
     * @date 2021/6/16 23:54
     * @version 1.0
     */
    List<PurchaseByProductSpentRes> selectAdminPurchaseSpentByProductPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("companyId") Long companyId,@Param("start") int start,@Param("end") int end);

    /**
     * @description: industry:前10 industryId 每日数据 明细数据
     * @author kyyang
     * @date 2021/6/19 22:43
     * @version 1.0
     */
    List<DateValueVO> selectIndustryDetailByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("industryId") Long industryId);

    /**
     * @description: industry：分页查询 总记录数
     * @author kyyang
     * @date 2021/6/21 21:40
     * @version 1.0
     */
    Integer selectAdminIndustryQueryPagePageCount(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("industryName")  String industryName);

    /**
     * @description: industry：分页查询 记录明细
     * @author kyyang
     * @date 2021/6/21 21:52
     * @version 1.0
     */
    List<AdminIndustryQueryRes> selectAdminIndustryQueryPagePageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("industryName") String industryName,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 查询某一个产业的汇总明细
     * @author kyyang
     * @date 2021/6/21 22:09
     * @version 1.0
     */
    List<DateValueVO> selectAdminIndustryQueryOne(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("industryId") String industryId);

    //管理员查询全部大订单的销售总额；
    List<DateValueVO> selectCategoryDetailByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("categoryId") String categoryId);
    //卖家查询自己目录销售总额；
    List<DateValueVO> selectSupplierCategoryDetailByTimeLine(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("categoryId") String categoryId,@Param("supplierId") Long supplierId);

    /**
     * @description: 管理员分页查询目录报告 总记录数
     * @author kyyang
     * @date 2021/6/22 21:41
     * @version 1.0
     */
    Integer selectAdminCategoryQueryPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("categoryName") String categoryName,@Param("supplierId") Long supplierId);

    //管理员查询目录分页报告
    List<AdminCategoryQueryPageRes> selectAdminCategoryQueryPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("categoryName") String categoryName, @Param("start") int start, @Param("end") int end);
    //卖家查询目录分页报告
    List<AdminCategoryQueryPageRes> selectSupplierCategoryQueryPageList(@Param("categoryId") String categoryId,@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("categoryName") String categoryName, @Param("start") int start, @Param("end") int end,@Param("supplierId") Long supplierId);
    /**
     * @description: 行业下产品属供销商 销售额分页查询 总记录数
     * @author kyyang
     * @date 2021/6/22 22:09
     * @version 1.0
     */
    Integer selectAdminIndustrySupplierPageCount(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("supplierName") String supplierName,@Param("industryId")Long industryId);

    /**
     * @description: 行业下产品属供销商 销售额分页查询 记录明细
     * @author kyyang
     * @date 2021/6/22 22:42
     * @version 1.0
     */
    List<AdminIndustrySupplierQueryRes> selectAdminIndustrySupplierQueryPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("sortType") int sortType, @Param("supplierName") String supplierName,@Param("start") int start,@Param("end") int end,@Param("industryId")Long industryId);

    //管理员查询某一目录详情
    List<DateValueVO> adminCategoryQueryOne(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("categoryId") String categoryId);
    //卖家查询某一目录详情
    List<DateValueVO> supplierCategoryQueryOne(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("categoryId") String categoryId,@Param("supplierId") Long supplierId);

    /**
     * @description: category：report_page 分页总记录数
     * @author kyyang
     * @date 2021/6/22 23:32
     * @version 1.0
     */
    Integer selectAdminCategoryQueryReportPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd, @Param("categoryName") String categoryName, @Param("industryId") String industryId,@Param("supplierId") Long supplierId);

   //管理员查询目录销售业绩
    List<AdminCategoryQueryReportPageRes> selectAdminCategoryQueryReportPageList(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd, int sortType, @Param("categoryName") String categoryName, @Param("industryId") String industryId, @Param("start") int start, @Param("end")int end);

    //买家查询目录销售业绩
    List<AdminCategoryQueryReportPageRes> selectSupplierCategoryQueryReportPageList(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd, int sortType, @Param("categoryName") String categoryName, @Param("industryId") String industryId, @Param("start") int start, @Param("end")int end,@Param("supplierId") Long supplierId);

    //管理员分析报告前10
    List<VariantQueryTopRes> selectAdminVariantQueryTop(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("topN") int topN);
    //卖家报告前10
    List<VariantQueryTopRes> selectSupplierVariantQueryTop(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("topN") int topN,@Param("supplierId") Long supplierId);
    //管理员查询单个茶品
    List<VariantQueryTopVO> selectAdminVariantQueryOneByTimeLine(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("variantId") String variantId);
    //卖家查询单个产品
    List<VariantQueryTopVO> selectSupplierVariantQueryOneByTimeLine(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("variantId") String variantId,@Param("supplierId") Long supplierId);

    /**
     * @description: 查询某一个目录子目录的销售额；根目录查一级；一级查二级；找parentId 等于 传入id的子目录就行了
     * @author kyyang
     * @date 2021/6/24 23:07
     * @version 1.0
     */
    List<CategoryQuerySubcategoryTotalfeeRes> selectAdminCategoryQuerySubcategoryTotalfee(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("categoryId") String categoryId);

   //管理员根据 variantId 时间段查询销售
    List<VariantQueryOneVO> selectAdminVariantQueryOneDetail(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("variantId") String variantId);
    //卖家根据 variantId 时间段查询销售
    List<VariantQueryOneVO> selectSupplierVariantQueryOneDetail(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("variantId") String variantId,@Param("supplierId") Long supplierId);

    //管理员根据 variantId ,ymd 查询单价 以及销售价
    VariantQueryOneVO selectVariantPriceAndSalesByYmd(@Param("variantId") String variantId,@Param("ymd") String ymd,@Param("supplierId") Long supplierId);

    /**
     * @description: 分页查询 sku 记录总数
     * @author kyyang
     * @date 2021/6/26 14:42
     * @version 1.0
     */
    Integer selectAdminVariantQueryPageCount(@Param("req") VariantQueryPageReq req);
    Integer selectSupplierVariantQueryPageCount(@Param("req") VariantQueryPageReq req,@Param("supplierId") Long supplierId);

   //管理员分页查询变体
    List<VariantQueryPageRes> selectAdminVariantQueryPageList(@Param("req")VariantQueryPageReq req);
    //卖家分页查询变体
    List<VariantQueryPageRes> selectSupplierVariantQueryPageList(@Param("req")VariantQueryPageReq req,@Param("supplierId") Long supplierId);

    /**
     * @description: 查询供应商统计
     * @author kyyang
     * @date 2021/6/26 17:01
     * @version 1.0
     */
    List<DateValueVO> adminSupplierQueryReport(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd);

    /**
     * @description: 分页查询供应商统计 统计数
     * @author kyyang
     * @date 2021/6/26 17:47
     * @version 1.0
     */
    Integer adminSupplierQueryPageCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("companyName") String companyName);

    /**
     * @description: 分页查询供应商统计 记录明细
     * @author kyyang
     * @date 2021/6/26 17:54
     * @version 1.0
     */
    List<SupplierQueryPageRes> adminSupplierQueryPageList(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("companyName") String companyName,@Param("sortType") int sortType,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 某一供应商报告
     * @author kyyang
     * @date 2021/6/26 19:00
     * @version 1.0
     */
    List<SupplierQueryOneVO> adminSupplierQueryOne(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("companyId") Long companyId);

    /**
     * @description: 查询某一个公司 时间范围内 目录销售额 总记录数
     * @author kyyang
     * @date 2021/6/26 19:21
     * @version 1.0
     */
    Integer adminSupplierQueryOneByCategoryCount(@Param("startTime") String timeBegin, @Param("endTime") String timeEnd,@Param("companyId")Long companyId,@Param("categoryName") String categoryName);

    /**
     * @description: 查询某一个公司 时间范围内 目录销售额 记录明细
     * @author kyyang
     * @date 2021/6/26 19:29
     * @version 1.0
     */
    List<SupplierQueryOneByCategoryRes> adminSupplierQueryOneByCategoryList(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd, @Param("companyId")Long companyId,@Param("categoryName") String categoryName,@Param("sortType") int sortType,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 某卖家下买家消费分页 总记录数
     * @author kyyang
     * @date 2021/6/26 20:37
     * @version 1.0
     */
    Integer adminSupplierQueryOneByPurchasePageCount(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd ,@Param("supplierId") String supplierId,@Param("companyName") String companyName);

    /**
     * @description: 某卖家下买家消费分页 记录明细
     * @author kyyang
     * @date 2021/6/26 20:42
     * @version 1.0
     */
    List<SupplierQueryOneByPurchaseRes> selectAdminSupplierQueryOneByPurchasePageList(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd ,@Param("supplierId") String supplierId,@Param("companyName") String companyName,@Param("sortType") int sortType,@Param("start") int start,@Param("end") int end);

    /**
     * @description: 某张券消费情况
     * @author kyyang
     * @date 2021/6/26 21:06
     * @version 1.0
     */
    List<DateValueVO> selectAdminCouponQueryOne(@Param("startTime") String timeBegin, @Param("endTime")String timeEnd,@Param("couponCode") String couponCode);

}
